package com.haiyou.oss.alibaba.config;

import com.haiyou.oss.alibaba.properties.AliOSSProperties;
import com.haiyou.oss.alibaba.service.AliOSSService;
import com.haiyou.oss.alibaba.service.impl.AliOSSServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动配置
 */
@Configuration
@EnableConfigurationProperties(value = AliOSSProperties.class)
@ConditionalOnProperty(prefix = AliOSSProperties.PREFIX, name = "enable", havingValue = "true")
public class AliOSSAutoConfiguration {

    @Bean
    public AliOSSService aliYunOSSService(AliOSSProperties properties) {
        return new AliOSSServiceImpl(properties);
    }

}
